package com.aspose.cells.a.d;

import com.aspose.cells.CellsHelper;
import com.aspose.cells.Encoding;
import java.awt.Font;
import java.awt.font.TextAttribute;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map.Entry;

public class zfs {
   public static ArrayList<String> a = new ArrayList();
   public static ArrayList<String> b = new ArrayList();
   static String c;
   zu d;
   public com.aspose.cells.b.a.a.zd e;
   private zao g;
   private zbd h;
   private zbx i;
   private HashMap j;
   private zap k;
   private zbf l;
   private zaa m;
   private zfi n;
   private zv o;
   private com.aspose.cells.b.a.d.zh p;
   private com.aspose.cells.b.a.d.zh q;
   private com.aspose.cells.b.a.d.zh r;
   private static HashMap s = com.aspose.cells.a.c.zg.a();
   private static HashMap t = com.aspose.cells.a.c.zg.a();
   private static HashMap u = com.aspose.cells.a.c.zg.a();
   private static HashMap v = com.aspose.cells.a.c.zg.a();
   private static HashMap w = com.aspose.cells.a.c.zg.a();
   private static HashMap x = com.aspose.cells.a.c.zg.a();
   private static HashMap y = com.aspose.cells.a.c.zg.a();
   private static HashMap z = com.aspose.cells.a.c.zg.a();
   private static HashMap A = com.aspose.cells.a.c.zg.a();
   private static String[] B = new String[]{"head", "hhea", "maxp", "hmtx", "fpgm", "prep", "cvt ", "loca", "glyf"};
   private static String[] C = new String[]{"OS/2", "name", "cmap", "post"};
   private static int[] D = new int[]{0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4};
   private zfj E = new zfj();
   static com.aspose.cells.a.f.zi f = null;
   private static zfq F = null;
   private static final com.aspose.cells.b.c.a.za G = new com.aspose.cells.b.c.a.za(new String[]{".ttc", ".otf", ".ttf"});

   public static String a() {
      return a.size() == 0 ? "" : (String)a.get(0);
   }

   public static void a(String var0) {
      a = new ArrayList();
      a.add(var0);
   }

   private static void h(String var0) {
      a(var0, false);
   }

   private static void a(String var0, Boolean var1) {
      if (var0 != null && !var0.trim().equals("")) {
         if (a == null) {
            a = new ArrayList();
         }

         a.add(var0);
         if (var1) {
            File var2 = new File(var0);
            if (var2.exists() && var2.isDirectory()) {
               File[] var3 = (new File(var0)).listFiles();
               File[] var4 = var3;
               int var5 = var3.length;

               for(int var6 = 0; var6 < var5; ++var6) {
                  File var7 = var4[var6];
                  if (var7.isDirectory()) {
                     a(var7.getAbsolutePath(), true);
                  }
               }
            }
         }

      }
   }

   static zfq a(String var0, int var1, boolean var2) throws Exception {
      HashMap var4 = A;
      synchronized(A) {
         zfr var3 = (zfr)A.get(var0);
         if (var3 == null) {
            var3 = c(var0);
            if (var3 == null) {
               return null;
            }

            A.put(var0, var3);
         }

         return var3.a(var1, var2);
      }
   }

   public static String b(String var0) {
      HashMap var1 = t;
      synchronized(t) {
         String var2 = (String)t.get(var0);
         if (var2 != null) {
            return var2;
         } else {
            Iterator var3 = s.entrySet().iterator();

            while(var3.hasNext()) {
               Entry var4 = (Entry)var3.next();
               com.aspose.cells.a.e.zd var5 = (com.aspose.cells.a.e.zd)var4.getKey();
               if (var5.equals(var0)) {
                  var2 = var0;
               }

               HashMap var6 = (HashMap)s.get(var5);
               if (var6.size() != 0) {
                  if (var6.containsKey(var0)) {
                     var2 = var5.toString();
                  }

                  if (var2 != null && var2.length() > 0) {
                     t.put(var0, var2);
                     return var2;
                  }
               }
            }

            t.put(var0, var0);
            return var0;
         }
      }
   }

   public static Font a(String var0, int var1, float var2, boolean var3) throws Exception {
      String var4 = var0 + var1 + "_" + var2;
      Object var5 = w.get(var4);
      if (var5 != null) {
         return (Font)var5;
      } else {
         HashMap var6 = w;
         synchronized(w) {
            var5 = w.get(var4);
            if (var5 != null) {
               return (Font)var5;
            } else {
               var5 = u.get(var0 + var1);
               Font var7 = null;
               if (var5 == null) {
                  var7 = c(var0, var1, var3);
               } else {
                  var7 = (Font)var5;
               }

               var7 = var7.deriveFont(var1, var2);
               Hashtable var8 = new Hashtable();
               if (!var7.getFamily().equals(var0)) {
                  var8.put(TextAttribute.FAMILY, var0);
               }

               var8.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
               var8.put(TextAttribute.SIZE, new Float(var2));
               com.aspose.cells.b.a.b.zg.a(var8, var1, false);
               var7 = var7.deriveFont(var8);
               w.put(var4, var7);
               return var7;
            }
         }
      }
   }

   private static Font c(String var0, int var1, boolean var2) throws Exception {
      HashMap var3 = u;
      synchronized(u) {
         Object var4 = u.get(var0 + var1);
         if (var4 != null) {
            return (Font)var4;
         } else {
            zfq var6 = null;
            String var7 = " ";

            try {
               if (var0.startsWith("UNHCR_Map_")) {
                  var0 = "Wingdings";
               }

               var7 = var0 + var1 + (var2 ? 'T' : 'F');
               var6 = (zfq)v.get(var7);
               if (var6 == null) {
                  var6 = a(b(var0), var1, var2);
               }
            } catch (Exception var11) {
               var6 = a("Arial", var1, var2);
            }

            if (var6 == null) {
               if (zei.a()) {
                  var6 = a("Arial Unicode MS", var1, var2);
                  if (var6 == null) {
                     var6 = a("Arial", var1, var2);
                  }
               } else {
                  var6 = a("Arial", var1, var2);
               }
            }

            Font var5;
            if (var6 == null) {
               var5 = new Font("Serif", var1, 10);
               u.put(var0 + var1, var5);
            } else {
               HashMap var8 = v;
               synchronized(v) {
                  if (!v.containsKey(var7)) {
                     v.put(var7, var6);
                  }
               }

               var4 = x.get(var6.e());
               if (var4 == null) {
                  var5 = i(var6.e());
               } else {
                  var5 = (Font)var4;
               }
            }

            return var5;
         }
      }
   }

   private static Font i(String var0) throws Exception {
      HashMap var1 = x;
      synchronized(x) {
         Object var2 = x.get(var0);
         if (var2 != null) {
            return (Font)var2;
         } else {
            new zfs(false);
            Font var3 = Font.createFont(0, new File(var0));
            x.put(var0, var3);
            return var3;
         }
      }
   }

   public static zfq b(String var0, int var1, boolean var2) throws Exception {
      zfq var3 = null;
      String var4 = " ";

      try {
         if (var0.startsWith("UNHCR_Map_")) {
            var0 = "Wingdings";
         }

         var4 = var0 + var1 + (var2 ? 'T' : 'F');
         var3 = (zfq)v.get(var4);
         if (var3 != null) {
            return var3;
         }

         var3 = a(b(var0), var1, var2);
      } catch (Exception var8) {
         var3 = a("Arial", var1, var2);
      }

      if (var3 == null && zei.a()) {
         var3 = a("Arial Unicode MS", var1, var2);
      }

      if (var3 == null) {
         var3 = a("Arial", var1, var2);
      }

      if (var3 == null) {
         var3 = a("SansSerif", var1, var2);
      }

      if (var3 == null) {
         if (F == null) {
            F = r();
         }

         var3 = F;
      }

      HashMap var5 = v;
      synchronized(v) {
         v.put(var4, var3);
         return var3;
      }
   }

   zfq a(String var1, String var2) throws Exception {
      HashMap var4 = z;
      synchronized(z) {
         zfq var3 = (zfq)z.get(var1 + var2);
         if (var3 == null) {
            var3 = this.b(var1, var2);
            var3.e(var1);
            var3.a(this.k);
            z.put(var1 + var2, var3);
         }

         return var3;
      }
   }

   zfq b(String var1, String var2) throws Exception {
      long var3 = 0L;
      c = var1;
      com.aspose.cells.b.a.d.ze var5 = com.aspose.cells.b.a.d.zd.b(var1);

      zfq var17;
      try {
         this.d = new zu(var5);
         if (!var1.toLowerCase().endsWith("ttc")) {
            var3 = 0L;
         } else {
            long var6 = this.a(this.d);

            for(long var8 = 0L; (var8 & 4294967295L) < (var6 & 4294967295L); ++var8) {
               var3 = 12L + (var8 & 4294967295L) * 4L;
               var5.a(var3, 0);
               var3 = this.d.c() & 4294967295L;
               var5.a(var3, 0);
               this.b();
               this.c();
               HashMap var10 = this.f();
               Iterator var11 = var10.values().iterator();

               while(var11.hasNext()) {
                  HashMap var12 = (HashMap)var11.next();
                  if (var12.get(4) != null && ((String)var12.get(4)).equals(var2)) {
                     var5.a(var3, 0);
                     this.b();
                     this.c();
                     this.g();
                     this.h();
                     this.d();
                     this.e();
                     this.i();
                     this.j();
                     zfq var13 = this.k();
                     return var13;
                  }
               }
            }
         }

         var5.a(var3, 0);
         this.b();
         this.c();
         this.g();
         this.h();
         this.d();
         this.e();
         this.i();
         this.j();
         var17 = this.k();
      } finally {
         if (var5 != null) {
            var5.a();
         }

      }

      return var17;
   }

   void a(zfq var1, zfj var2, zfj var3, com.aspose.cells.b.a.d.zm var4, boolean var5, boolean var6) throws Exception {
      if (var1 == null) {
         throw new IllegalArgumentException("font");
      } else if (var3 == null) {
         throw new IllegalArgumentException("oldToNewGlyphIndexes");
      } else if (var4 == null) {
         throw new IllegalArgumentException("dstStream");
      } else {
         com.aspose.cells.b.a.d.ze var7 = com.aspose.cells.b.a.d.zd.b(var1.e());

         try {
            this.d = new zu(var7);
            long var8 = 0L;
            if (var1.e().toLowerCase().endsWith("ttc")) {
               long var10 = this.a(this.d);

               for(long var12 = 0L; (var12 & 4294967295L) < (var10 & 4294967295L); ++var12) {
                  var8 = 12L + (var12 & 4294967295L) * 4L;
                  var7.a(var8, 0);
                  var8 = this.d.c() & 4294967295L;
                  var7.a(var8, 0);
                  this.b();
                  this.c();
                  this.g();
                  if (((String)this.j.get(4)).equals(var1.b())) {
                     break;
                  }
               }
            } else {
               var8 = 0L;
            }

            var7.a(var8, 0);
            this.b();
            this.c();
            this.d();
            this.e();
            this.i();
            if (var5) {
               this.j();
               this.o();
            }

            boolean var17 = this.g.n == 0;
            zau var11 = new zau(this.d, var17, this.l);
            int var18 = var11.a(this.e("loca"), this.e("glyf"), var3);
            if ((var18 & '\uffff') != var3.a()) {
               throw new IllegalStateException("Unexpected used glyphs count!");
            }

            this.p = var11.a();
            this.q = var11.b();
            this.r = var11.c();
            this.i.b = var18;
            this.h.q = var18;
            if (var5) {
               this.m.a(var2);
               this.n.a(var3);
            }

            this.a(var5, var4);
         } finally {
            if (var7 != null) {
               var7.a();
            }

         }

      }
   }

   void a(zfq var1, zfj var2, com.aspose.cells.b.a.d.zm var3, boolean var4, boolean var5) throws Exception {
      if (var1 == null) {
         throw new IllegalArgumentException("font");
      } else if (var2 == null) {
         throw new IllegalArgumentException("usedGlyphs");
      } else if (var3 == null) {
         throw new IllegalArgumentException("dstStream");
      } else {
         com.aspose.cells.b.a.d.ze var6 = com.aspose.cells.b.a.d.zd.b(var1.e());

         try {
            this.d = new zu(var6);
            long var7 = 0L;
            if (var1.e().toLowerCase().endsWith("ttc")) {
               long var9 = this.a(this.d);

               for(long var11 = 0L; (var11 & 4294967295L) < (var9 & 4294967295L); ++var11) {
                  var7 = 12L + (var11 & 4294967295L) * 4L;
                  var6.a(var7, 0);
                  var7 = this.d.c() & 4294967295L;
                  var6.a(var7, 0);
                  this.b();
                  this.c();
                  this.g();
                  if (((String)this.j.get(4)).equals(var1.b())) {
                     break;
                  }
               }
            } else {
               var7 = 0L;
            }

            var6.a(var7, 0);
            if (var5 || var1.x()) {
               zcq.a(var1.e(), var3);
            }

            this.b();
            this.c();
            this.d();
            this.e();
            this.i();
            if (var4) {
               this.j();
               this.o();
            }

            try {
               boolean var18 = this.g.n == 0;
               zau var10 = new zau(this.d, var18, this.l);
               int var20 = var10.a(this.e("loca"), this.e("glyf"), var2);
               this.p = var10.a();
               this.q = var10.b();
               this.r = var10.c();
               this.i.b = var20;
               this.h.q = var20;
            } catch (Exception var16) {
               com.aspose.cells.a.e.zf.a((Throwable)var16);
            }

            this.o = new zv(var3);
            int var19 = this.l();
            this.o.a().b((long)var19);
            this.m();
            this.o.a().b(0L);
            this.l();
         } finally {
            if (var6 != null) {
               var6.a();
            }

         }

      }
   }

   private void a(boolean var1, com.aspose.cells.b.a.d.zm var2) throws Exception {
      this.o = new zv(var2);
      int var3 = this.a(var1);
      this.o.a().b((long)var3);
      this.b(var1);
      this.o.a().b(0L);
      this.a(var1);
   }

   private int a(boolean var1) throws Exception {
      this.o.a(65536);
      ArrayList var2 = new ArrayList();
      this.a(B, var2);
      if (var1) {
         this.a(C, var2);
      }

      this.o.b(var2.size());
      int var3 = D[var2.size()];
      int var4 = (1 << var3) * 16;
      this.o.b(var4);
      this.o.b(var3);
      int var5 = var2.size() * 16 - var4;
      this.o.b(var5);
      int var6 = (int)this.o.a().i() + var2.size() * 16;
      Iterator var7 = var2.iterator();

      while(var7.hasNext()) {
         zfx var8 = (zfx)var7.next();
         var8.a(this.o);
      }

      return var6;
   }

   private void a(String[] var1, ArrayList var2) {
      String[] var3 = var1;
      int var4 = var1.length;

      for(int var5 = 0; var5 < var4; ++var5) {
         String var6 = var3[var5];
         zfx var7 = this.e(var6);
         if (var7 != null) {
            com.aspose.cells.b.a.a.ze.a(var2, (Object)var7);
         }
      }

   }

   private void b(boolean var1) throws Exception {
      this.f("head");
      this.a("hhea", this.h.a());
      this.a("maxp", this.i.a());
      this.a("hmtx", this.r);
      this.f("fpgm");
      this.f("prep");
      this.f("cvt ");
      this.a("loca", this.p);
      this.a("glyf", this.q);
      if (var1) {
         this.f("OS/2");
         this.f("name");
         this.a("cmap", this.m.b());
         this.a("post", this.n.b());
      }

   }

   private void o() throws Exception {
      this.d("post");
      this.n = new zfi(this.d);
   }

   static zfr c(String var0) throws Exception {
      zfr var1 = new zfr(var0);
      Iterator var3 = y.keySet().iterator();

      while(true) {
         String var2;
         do {
            do {
               String var5;
               String var6;
               do {
                  if (!var3.hasNext()) {
                     return var1;
                  }

                  com.aspose.cells.a.e.zd var4 = (com.aspose.cells.a.e.zd)var3.next();
                  var5 = var4.toString();
                  var6 = var5.substring(0, 0 + var5.indexOf("*$"));
               } while(!var6.equals(var0));

               var2 = (String)y.get(var5);
            } while(var2 == null);
         } while(var2.trim().equals(""));

         String var7 = com.aspose.cells.b.a.d.zk.d(var2);
         boolean var8 = zcq.b(var7, ".ttf") || zcq.b(var7, ".ttc") || zcq.b(var7, ".otf");
         if (var8) {
            zfs var9 = new zfs(false);

            try {
               zfq var10 = var9.a(var2, var0);
               var1.a(var10);
            } catch (Exception var11) {
               ;
            }
         }
      }
   }

   void b() throws Exception {
      int var1 = this.d.b();
      this.e = new com.aspose.cells.b.a.a.zd();
      int var2 = this.d.e() & '\uffff';
      int var3 = this.d.e() & '\uffff';
      int var4 = this.d.e() & '\uffff';
      int var5 = this.d.e() & '\uffff';

      for(int var6 = 0; var6 < var2; ++var6) {
         zfx var7 = new zfx(this.d);
         this.e.a(var7.a, var7);
      }

   }

   void c() throws Exception {
      this.d("head");
      this.g = new zao(this.d);
   }

   void d() throws Exception {
      this.d("hhea");
      this.h = new zbd(this.d);
   }

   void e() throws Exception {
      this.d("maxp");
      this.i = new zbx(this.d);
   }

   HashMap f() throws Exception {
      this.d("name");
      int var1 = (int)this.d.a().i();
      int var2 = this.d.e();
      if ((var2 & '\uffff') != 0) {
         throw new UnsupportedOperationException("Unknown name table format.");
      } else {
         int var3 = this.d.e();
         int var4 = this.d.e();
         HashMap var5 = new HashMap();
         HashMap var6 = null;

         for(int var7 = 0; var7 < (var3 & '\uffff'); ++var7) {
            int var8 = this.d.e();
            int var9 = this.d.e();
            int var10 = this.d.e();
            int var11 = this.d.e();
            int var12 = this.d.e();
            int var13 = this.d.e();
            if (((var9 & '\uffff') == 1 || (var9 & '\uffff') == 0) && (var10 & '\uffff') != 0) {
               if (!var5.containsKey(var10)) {
                  var6 = new HashMap();
                  var5.put(var10, var6);
               } else {
                  var6 = (HashMap)var5.get(var10);
               }

               int var14 = (int)this.d.a().i();
               this.d.a().b((long)(var1 + (var4 & '\uffff') + (var13 & '\uffff')));
               byte[] var15 = this.d.a(var12 & '\uffff');
               var6.put(var11 & '\uffff', Encoding.getBigEndianUnicode().a(var15));
               this.d.a().b((long)var14);
            }
         }

         return var5;
      }
   }

   void g() throws Exception {
      this.d("name");
      int var1 = (int)this.d.a().i();
      int var2 = this.d.e();
      if ((var2 & '\uffff') != 0) {
         throw new UnsupportedOperationException("Unknown name table format.");
      } else {
         int var3 = this.d.e();
         int var4 = this.d.e();
         this.j = new HashMap();

         for(int var5 = 0; var5 < (var3 & '\uffff'); ++var5) {
            int var6 = this.d.e();
            int var7 = this.d.e();
            int var8 = this.d.e();
            int var9 = this.d.e();
            int var10 = this.d.e();
            int var11 = this.d.e();
            if ((var6 & '\uffff') == 3 && ((var7 & '\uffff') == 1 || (var7 & '\uffff') == 0) && (var8 & '\uffff') == 1033) {
               int var12 = (int)this.d.a().i();
               this.d.a().b((long)(var1 + (var4 & '\uffff') + (var11 & '\uffff')));
               byte[] var13 = this.d.a(var10 & '\uffff');
               this.j.put(var9 & '\uffff', Encoding.getBigEndianUnicode().a(var13));
               this.d.a().b((long)var12);
            }
         }

      }
   }

   void h() throws Exception {
      this.d("OS/2");
      this.k = new zap(this.d);
   }

   void i() throws Exception {
      if (this.h == null) {
         throw new IllegalStateException("Need to read horizontal header first.");
      } else if (this.i == null) {
         throw new IllegalStateException("Need to read maximum profile first.");
      } else {
         this.d("hmtx");
         this.l = new zbf(this.d, this.h.q & '\uffff', this.i.b & '\uffff');
      }
   }

   void j() throws Exception {
      this.d("cmap");
      this.m = new zaa(this.d);
   }

   zfq k() throws Exception {
      zfq var1 = new zfq();
      var1.b(this.g.f);
      var1.l(this.g.g);
      var1.m(this.g.h);
      var1.n(this.g.i);
      var1.o(this.g.j);
      var1.a(this.b(1));
      var1.b(this.b(2));
      var1.c(this.b(4));
      var1.d(this.a(6));
      var1.c(this.h.b);
      var1.d(Math.abs(this.h.c));
      var1.e(var1.i() + var1.j() + this.h.d);
      var1.c((float)(-Math.atan2((double)this.h.j, (double)this.h.i) * 180.0D / 3.141592653589793D));
      var1.q(this.h.e);
      var1.r(this.g.e);
      var1.f(this.k.n);
      var1.k(this.k.o);
      var1.i(this.k.g);
      var1.j(this.k.i);
      var1.g(this.k.k);
      var1.h(this.k.m);
      var1.a(this.k.a());
      var1.p(this.k.H);
      var1.a(this.e("loca"));
      var1.b(this.e("glyf"));
      zfx var2 = this.e("VDMX");
      var1.a(this.g.n == 0);
      var1.a(this.m.a(this.l, var1.b()));
      var1.a(this.m);
      var1.a(new zbc(this.d, this.e("hdmx"), var1.f().size() + 1));
      var1.a(this.l);
      zfx var3 = this.e("CFF ");
      if (var3 != null) {
         var1.c(true);
         this.d.a().b((long)var3.c);
         zac var4 = new zac(this.d);
         var1.d(var4.a());
      }

      byte var6 = 4;
      byte var5 = 8;
      var1.b((this.k.e & '\uffff' & var6) != 0 && (this.k.e & '\uffff' & var5) == 0);
      return var1;
   }

   void d(String var1) throws Exception {
      zfx var2 = this.e(var1);
      this.d.a().b((long)var2.c);
   }

   zfx e(String var1) {
      zfx var2 = (zfx)this.e.d((Object)var1);
      return var2 == null ? null : var2;
   }

   String a(int var1) {
      return (String)this.j.get(var1);
   }

   String b(int var1) {
      String var2 = this.a(var1);
      if (var2 == null) {
         throw new IllegalStateException("Requested a name string that is not present in the font.");
      } else {
         return var2;
      }
   }

   int l() throws Exception {
      this.o.a(65536);
      int var1 = B.length;
      this.o.c(var1);
      int var2 = D[var1];
      int var3 = (1 << var2) * 16;
      this.o.c(var3);
      this.o.c(var2);
      int var4 = var1 * 16 - var3;
      this.o.c(var4);
      int var5 = (int)this.o.a().i() + var1 * 16;

      for(int var6 = 0; var6 < var1; ++var6) {
         zfx var7 = this.e(B[var6]);
         if (var7 != null) {
            var7.a(this.o);
         }
      }

      return var5;
   }

   void m() throws Exception {
      this.f("head");
      this.a("hhea", this.h.a());
      this.a("maxp", this.i.a());
      this.a("hmtx", this.r);
      this.f("fpgm");
      this.f("prep");
      this.f("cvt ");
      this.a("loca", this.p);
      this.a("glyf", this.q);
   }

   void a(String var1, com.aspose.cells.b.a.d.zh var2) throws Exception {
      zfx var3 = this.e(var1);
      var3.c = (int)this.o.a().i();
      this.o.a(var2.m(), 0, (int)var2.h());
      var3.b = zfx.a(var2.m(), 0, (int)var2.h());
      var3.d = (int)var2.h();
      this.n();
   }

   void f(String var1) throws Exception {
      try {
         zfx var2 = this.e(var1);
         this.d.a().b((long)var2.c);
         byte[] var3 = this.d.a(var2.d);
         var2.c = (int)this.o.a().i();
         this.o.a(var3, 0, var3.length);
         this.n();
      } catch (Exception var4) {
         ;
      }

   }

   void n() throws Exception {
      zcq.a(this.o.a(), 4);
   }

   long a(zu var1) throws Exception {
      var1.a(8);
      return var1.c();
   }

   ArrayList g(String var1) throws Exception {
      ArrayList var2 = new ArrayList();
      c = var1;
      String var5 = "";
      String var6 = "";
      com.aspose.cells.b.a.d.ze var7 = com.aspose.cells.b.a.d.zd.b(var1);

      ArrayList var23;
      try {
         this.d = new zu(var7);
         HashMap var8 = null;
         label213:
         switch(G.a(com.aspose.cells.b.a.d.zk.d(var1).toLowerCase())) {
         case 0:
            long var9 = this.a(this.d);

            for(long var25 = 0L; (var25 & 4294967295L) < (var9 & 4294967295L); ++var25) {
               long var3 = 12L + (var25 & 4294967295L) * 4L;
               var7.a(var3, 0);
               var3 = this.d.c() & 4294967295L;
               var7.a(var3, 0);
               this.b();
               this.c();
               var8 = this.f();
               if (var8.containsKey(1033)) {
                  var6 = (String)((HashMap)var8.get(1033)).get(1);
                  if (var6 == null) {
                     break label213;
                  }
               }

               Iterator var26 = var8.values().iterator();

               while(var26.hasNext()) {
                  HashMap var27 = (HashMap)var26.next();
                  String var28 = (String)var27.get(2);
                  String var16 = "";
                  if (var27.get(1) != null) {
                     var16 = (String)var27.get(1);
                  }

                  if (var16.length() > 0 && !var5.equals(var16)) {
                     if (!s.containsKey(var6)) {
                        s.put(var6, new HashMap());
                     }

                     HashMap var17 = (HashMap)s.get(var6);
                     if (!var6.equals(var16)) {
                        var17.put(var16, 0);
                     }

                     var5 = var16;
                     com.aspose.cells.b.a.a.ze.a(var2, (Object)(var6 + "*$" + var27.get(2)));
                  }
               }
            }
            break;
         case 1:
         case 2:
            label229: {
               this.b();
               this.c();
               var8 = this.f();
               if (var8.containsKey(1033)) {
                  var6 = (String)((HashMap)var8.get(1033)).get(1);
                  if (var6 == null) {
                     break label229;
                  }

                  try {
                     HashMap var11;
                     if (zbw.c < var7.h()) {
                        var11 = (HashMap)var8.get(1033);
                        if ("regular".equals(((String)var11.get(2)).toLowerCase())) {
                           zbw.a = (String)var11.get(1);
                           zbw.c = var7.h();
                           zbw.b = (String)var11.get(2);
                        }
                     }

                     if (zbw.f < var7.h()) {
                        var11 = (HashMap)var8.get(1033);
                        if ("bold".equals(((String)var11.get(2)).toLowerCase())) {
                           zbw.d = (String)var11.get(1);
                           zbw.f = var7.h();
                           zbw.e = (String)var11.get(2);
                        }
                     }
                  } catch (Exception var21) {
                     ;
                  }
               }

               Iterator var24 = var8.values().iterator();

               while(var24.hasNext()) {
                  HashMap var12 = (HashMap)var24.next();
                  String var13 = (String)var12.get(2);
                  String var14 = "";
                  if (var12.get(1) != null) {
                     var14 = (String)var12.get(1);
                  }

                  if (var14.length() > 0 && var14.length() > 0 && !var5.equals(var14)) {
                     if (!s.containsKey(var6)) {
                        s.put(var6, new HashMap());
                     }

                     HashMap var15 = (HashMap)s.get(var6);
                     if (!var6.equals(var14)) {
                        var15.put(var14, 0);
                     }

                     var5 = var14;
                     com.aspose.cells.b.a.a.ze.a(var2, (Object)(var6 + "*$" + var12.get(2)));
                  }
               }
            }
         }

         var23 = var2;
      } finally {
         if (var7 != null) {
            var7.a();
         }

      }

      return var23;
   }

   private void p() throws Exception {
      String var2 = "";
      String var1 = com.aspose.cells.a.za.a("Aspose.Cells.FontDirExc");
      if (var1 != null && !var1.trim().equals("")) {
         h(var1);
      } else {
         h("c:\\windows\\fonts\\");
         h("c:\\winnt\\fonts\\");
         a("/usr/share/fonts", true);
         a("/usr/local/share/fonts", true);
         h("/Library/Fonts");
         var1 = com.aspose.cells.a.za.a("com.aspose.cells.fontdir");
         h(var1);
         var1 = com.aspose.cells.a.za.a("java.home");
         if (var1 != null) {
            h(var1 + "/lib/fonts");
         }

         switch(2) {
         case 1:
         case 2:
            if (com.aspose.cells.a.za.c < 3) {
               String var3 = com.aspose.cells.a.za.a("java.vendor");
               if (var3 == null || var3.startsWith("Sun ")) {
                  var3 = com.aspose.cells.a.za.a("Aspose.Cells.Disable");
                  if (var3 == null || var3.indexOf("SunFontManager") < 0) {
                     try {
                        Class var4 = Class.forName("sun.font.FontManager");
                        Method var5 = var4.getMethod("getFontPath", Boolean.TYPE);
                        String var6 = (String)var5.invoke((Object)null, Boolean.TRUE);
                        if (var6 != null) {
                           String[] var7 = var6.split(File.pathSeparator);
                           int var8 = var7.length;

                           for(int var9 = 0; var9 < var8; ++var9) {
                              String var10 = var7[var9];
                              h(var10);
                           }
                        }
                     } catch (Throwable var15) {
                        com.aspose.cells.a.e.zf.a("SunFontManager Error", var15);
                     }
                  }
               }
            }
         }
      }

      Iterator var16;
      if (a.size() != 0) {
         var16 = a.iterator();

         while(var16.hasNext()) {
            Object var17 = var16.next();
            String[] var19 = com.aspose.cells.b.a.d.zc.c((String)var17);
            int var21 = var19.length;

            for(int var23 = 0; var23 < var21; ++var23) {
               String var25 = var19[var23];
               String var26 = var25.toLowerCase();
               if (var26.endsWith("ttf") || var26.endsWith("ttc")) {
                  try {
                     ArrayList var27 = this.g(var25);
                     Iterator var11 = var27.iterator();

                     while(var11.hasNext()) {
                        Object var12 = var11.next();
                        if (var12 != null && !y.containsKey((String)var12)) {
                           y.put((String)var12, var25);
                        }
                     }
                  } catch (Exception var14) {
                     com.aspose.cells.a.e.zf.a("Unsupported font file: " + var25);
                     com.aspose.cells.a.e.zf.a((Throwable)var14);
                  }
               }
            }
         }
      }

      if (CellsHelper.getFontFiles().size() > 0) {
         var16 = CellsHelper.getFontFiles().iterator();

         while(var16.hasNext()) {
            String var18 = (String)var16.next();

            try {
               ArrayList var20 = this.g(var18);
               Iterator var22 = var20.iterator();

               while(var22.hasNext()) {
                  Object var24 = var22.next();
                  if (var24 != null && !y.containsKey((String)var24)) {
                     y.put((String)var24, var18);
                  }
               }
            } catch (Exception var13) {
               com.aspose.cells.a.e.zf.a("Unsupported font file: " + var18);
               com.aspose.cells.a.e.zf.a((Throwable)var13);
            }
         }
      }

   }

   private zfq q() throws Exception {
      com.aspose.cells.b.a.d.zm var1 = com.aspose.cells.a.c.zy.a("Aspose.Cells.geo_1.ttf");

      zfq var3;
      try {
         this.d = new zu(var1);
         var1.a(0L, 0);
         this.b();
         this.c();
         this.g();
         this.h();
         this.d();
         this.e();
         this.i();
         this.j();
         zfq var2 = this.k();
         var2.e(true);
         var2.a(this.k);
         var2.e("");
         var3 = var2;
      } finally {
         if (var1 != null) {
            var1.a();
         }

      }

      return var3;
   }

   private static zfq r() throws Exception {
      zfs var0 = new zfs(false);
      return var0.q();
   }

   private void s() throws Exception {
      f = new com.aspose.cells.a.f.zi(com.aspose.cells.a.c.zv.c("Aspose.Cells.font.zip"));
   }

   public zfs(boolean var1) {
      HashMap var2 = y;
      synchronized(y) {
         if (y.size() == 0 || var1) {
            t.clear();

            try {
               if (f == null) {
                  this.s();
               }

               this.p();
            } catch (Exception var5) {
               ;
            }
         }

      }
   }

   public static zfq a(int var0, char var1) throws Exception {
      zfq var2 = null;
      Iterator var3 = s.entrySet().iterator();

      while(var3.hasNext()) {
         Entry var4 = (Entry)var3.next();
         com.aspose.cells.a.e.zd var5 = (com.aspose.cells.a.e.zd)var4.getKey();
         var2 = b(var5.toString(), var0, false);
         if (var2.f().containsKey(var1)) {
            break;
         }
      }

      return var2;
   }

   public static zfq a(int var0, String var1) throws Exception {
      if (var1 != null && var1.length() != 0) {
         zfq var2 = null;
         Iterator var3 = s.entrySet().iterator();

         while(var3.hasNext()) {
            Entry var4 = (Entry)var3.next();
            com.aspose.cells.a.e.zd var5 = (com.aspose.cells.a.e.zd)var4.getKey();
            var2 = b(var5.toString(), var0, false);

            int var6;
            for(var6 = 0; var6 < var1.length(); ++var6) {
               char var7 = var1.charAt(var6);
               if (var7 != '\n' && var7 != '\r') {
                  if (var2.b().equals("Symbol") && var7 >= '\uf020' && var7 <= '\uf0ff') {
                     var7 = (char)(var7 & 255);
                  }

                  if (!var2.f().containsKey(var7)) {
                     var2 = null;
                     break;
                  }
               }
            }

            if (var6 == var1.length() && var2 != null) {
               break;
            }
         }

         return var2;
      } else {
         return null;
      }
   }

   public static boolean a(String var0, int var1, String var2) throws Exception {
      return a(var0, var1, var2, false);
   }

   public static boolean a(String var0, int var1, String var2, boolean var3) throws Exception {
      zfq var4 = b(var0, var1, false);
      if (var4.z()) {
         return false;
      } else if (!var4.b().equalsIgnoreCase(b(var0))) {
         return false;
      } else if (var3 && (var1 & 1) != 0 && (var4.g() & 1) == 0) {
         return false;
      } else {
         for(int var5 = 0; var5 < var2.length(); ++var5) {
            char var6 = var2.charAt(var5);
            if (var6 != '\n' && var6 != '\r') {
               if (var4.b().equals("Symbol") && var6 >= '\uf020' && var6 <= '\uf0ff') {
                  var6 = (char)(var6 & 255);
               }

               if (!var4.f().containsKey(var2.charAt(var5))) {
                  return false;
               }
            }
         }

         return true;
      }
   }
}
